This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
install.packages('sf')
Error in install.packages : Updating loaded packages
install.packages('raster')
Error in install.packages : Updating loaded packages
install.packages('dplyr')
Error in install.packages : Updating loaded packages
install.packages('spData')
Error in install.packages : Updating loaded packages
install.packages('spDataLarge')
Installing package into 㤼㸱C:/Users/WHH/Documents/R/win-library/3.5㤼㸲
(as 㤼㸱lib㤼㸲 is unspecified)
Warning in install.packages :
package ‘spDataLarge’ is not available (for R version 3.5.2)
library(sf)
library(raster)
library(dplyr)
library(spData)
library(spDataLarge)
install.packages("spDataLarge", repos = "https://nowosad.github.io/drat/", type = "source")
Error in install.packages : Updating loaded packages
library(tmap)
library(leaflet)
library(mapview)
library(ggplot2)
library(shiny)
map_tract <- tm_shape(tract,name = 'X2018_Murde') + tm_polygons('X2018_Murde')+tm_shape(tract,name = 'X2018_Motor') + tm_polygons('X2018_Motor')+tm_shape(tract,name = 'X2018_Larce') + tm_polygons('X2018_Larce')+tm_shape(tract,name = 'X2018_Prope') + tm_polygons('X2018_Prope')+tm_shape(tract,name = 'X2018_Rape') + tm_polygons('X2018_Rape')
map_tract
library(car)
full.model <- lm(sub_df$X2018_Murde.1 ~sub_df$Mean_NTL + sub_df$Pop_Dens_1 + sub_df$Employ_R_1 + sub_df$Poverty__1 + sub_df$Educatio_1 + sub_df$Median_I_1 + sub_df$House_De_1 + sub_df$Vacant_R_1 + sub_df$House_Va_1 + sub_df$Room_Num_1)
reduced.model <- step(full.model, direction = 'backward')
Start: AIC=1396.79
sub_df$X2018_Murde.1 ~ sub_df$Mean_NTL + sub_df$Pop_Dens_1 +
sub_df$Employ_R_1 + sub_df$Poverty__1 + sub_df$Educatio_1 +
sub_df$Median_I_1 + sub_df$House_De_1 + sub_df$Vacant_R_1 +
sub_df$House_Va_1 + sub_df$Room_Num_1
Df Sum of Sq RSS AIC
- sub_df$House_De_1 1 4649 1605966 1395.2
- sub_df$House_Va_1 1 8349 1609665 1395.6
<none> 1601316 1396.8
- sub_df$Vacant_R_1 1 36966 1638282 1398.2
- sub_df$Poverty__1 1 50366 1651682 1399.4
- sub_df$Employ_R_1 1 103504 1704820 1404.1
- sub_df$Pop_Dens_1 1 110474 1711791 1404.7
- sub_df$Educatio_1 1 150665 1751982 1408.1
- sub_df$Median_I_1 1 186520 1787836 1411.1
- sub_df$Room_Num_1 1 247568 1848884 1416.1
- sub_df$Mean_NTL 1 533447 2134763 1437.3
Step: AIC=1395.22
sub_df$X2018_Murde.1 ~ sub_df$Mean_NTL + sub_df$Pop_Dens_1 +
sub_df$Employ_R_1 + sub_df$Poverty__1 + sub_df$Educatio_1 +
sub_df$Median_I_1 + sub_df$Vacant_R_1 + sub_df$House_Va_1 +
sub_df$Room_Num_1
Df Sum of Sq RSS AIC
- sub_df$House_Va_1 1 12100 1618066 1394.3
<none> 1605966 1395.2
- sub_df$Vacant_R_1 1 32868 1638834 1396.2
- sub_df$Poverty__1 1 46712 1652678 1397.5
- sub_df$Employ_R_1 1 103232 1709197 1402.4
- sub_df$Pop_Dens_1 1 140202 1746168 1405.6
- sub_df$Educatio_1 1 151193 1757158 1406.5
- sub_df$Median_I_1 1 192285 1798251 1410.0
- sub_df$Room_Num_1 1 243340 1849305 1414.1
- sub_df$Mean_NTL 1 565638 2171603 1437.9
Step: AIC=1394.33
sub_df$X2018_Murde.1 ~ sub_df$Mean_NTL + sub_df$Pop_Dens_1 +
sub_df$Employ_R_1 + sub_df$Poverty__1 + sub_df$Educatio_1 +
sub_df$Median_I_1 + sub_df$Vacant_R_1 + sub_df$Room_Num_1
Df Sum of Sq RSS AIC
<none> 1618066 1394.3
- sub_df$Vacant_R_1 1 35808 1653874 1395.6
- sub_df$Poverty__1 1 40946 1659012 1396.0
- sub_df$Employ_R_1 1 94801 1712867 1400.8
- sub_df$Pop_Dens_1 1 135438 1753504 1404.2
- sub_df$Educatio_1 1 141551 1759617 1404.7
- sub_df$Median_I_1 1 221933 1839999 1411.3
- sub_df$Room_Num_1 1 251779 1869845 1413.7
- sub_df$Mean_NTL 1 748308 2366374 1448.6
reduced.model
Call:
lm(formula = sub_df$X2018_Murde.1 ~ sub_df$Mean_NTL + sub_df$Pop_Dens_1 +
sub_df$Employ_R_1 + sub_df$Poverty__1 + sub_df$Educatio_1 +
sub_df$Median_I_1 + sub_df$Vacant_R_1 + sub_df$Room_Num_1)
Coefficients:
(Intercept) sub_df$Mean_NTL sub_df$Pop_Dens_1 sub_df$Employ_R_1
-296.00388 4.12917 -0.53812 50.41677
sub_df$Poverty__1 sub_df$Educatio_1 sub_df$Median_I_1 sub_df$Vacant_R_1
-11.31568 -39.52070 -0.00346 327.33486
sub_df$Room_Num_1
87.60889